package leo.data
{
	import flash.utils.Dictionary;
	
	import leo.game.display.BaseMonster;
	import leo.game.display.BaseTower;
	import leo.game.display.Bullet;
	import leo.game.display.MapObject;
	import leo.game.ui.UIBottom;

	/**
	 * 游戏数据 
	 * @author leo
	 * 
	 */
	public class GameModel
	{
		private static var _instance :GameModel = null;
		/**
		 *  地图上塔和怪物的图片链接数组 
		 */		
		public var imgList :Array = [];
		/**
		 *  塔和怪物的图片库 
		 */		
		public  var imgDict :Dictionary = new Dictionary();
		/**
		 * TowerVO总表数据 
		 */		
		public var towerVOList :Vector.<TowerVO> = new Vector.<TowerVO>();
		/**
		 * MonsterVO总表数据
		 */		
		public var monsterVOList :Vector.<MonsterVO> =  new Vector.<MonsterVO>();
		/**
		 * 所有关卡地图数据 
		 */		
		public var mapAry :Array = [];
		/**
		 * 地图上的防守塔
		 */		
		public var towerList :Vector.<BaseTower> = new Vector.<BaseTower>();
		/**
		 * 地图上的怪物 
		 */		
		public var monsterList :Vector.<BaseMonster> = new Vector.<BaseMonster>();
		/**
		 * 子弹列表 
		 */		
		public var bulletList :Vector.<Bullet> = new Vector.<Bullet>();
		/**
		 * 当前关卡 ,0为第一关，1为第二关，以此类推
		 */		
		public var curLevel :int = 0;
		/**
		 * 建筑数组，格式为[y][x] true为路障，false为可行走或可建
		 */	
		public var curMapAry :Array;
		/**
		 * 当前关卡可逃怪物数 
		 */		
		public var curMapHp :int = 1;
		/**
		 * 当前游戏是否结束 
		 */		
		public var isOver :Boolean;
		/**
		 * 当前小关卡的怪物数量 
		 */		
		public var curMapMonsterNum :int;
		/**
		 * 当前游戏金币 
		 */		
		public var curGameGold :int;
		/**
		 * 迎战次数 
		 */		
		public var battleNumber :int = 0;
		public function GameModel()
		{
		}
		
		
		public static function get instance():GameModel
		{
			if(_instance == null)
			{
				_instance = new GameModel();
			}
			return _instance;
			
		}
		
		public function clearData():void
		{
			this.isOver = true;
			this.battleNumber = 0;
			//删除防守塔数据
			if(this.towerList.length > 0)
			{
				for each(var tower :BaseTower in this.towerList)
				{
					tower.isAlive = false;
				}
			}
			
			//删除怪物数据
			
			if(this.monsterList.length > 0)
			{
				for each(var monster :BaseMonster in this.monsterList)
				{
					monster.isAlive = false;
				}
			}
		}
		
	}
}
